package com.ctalk.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ctalk.common.annotation.Log;
import com.ctalk.common.core.controller.BaseController;
import com.ctalk.common.core.domain.AjaxResult;
import com.ctalk.common.enums.BusinessType;
import com.ctalk.base.domain.WxappConfig;
import com.ctalk.base.service.IWxappConfigService;
import com.ctalk.common.utils.poi.ExcelUtil;
import com.ctalk.common.core.page.TableDataInfo;

/**
 * 微信App配置Controller
 * 
 * @author wanghuan
 * @date 2025-08-04
 */
@Api(tags = "微信App配置Controller")
@RestController
@RequestMapping("/base/wxapp_config")
public class WxappConfigController extends BaseController
{
    @Autowired
    private IWxappConfigService wxappConfigService;

    /**
     * 查询微信App配置列表
     */
    @ApiOperation("查询微信App配置列表")
    @PreAuthorize("@ss.hasPermi('base:wxapp_config:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxappConfig wxappConfig)
    {
        startPage();
        List<WxappConfig> list = wxappConfigService.selectWxappConfigList(wxappConfig);
        return getDataTable(list);
    }

    /**
     * 导出微信App配置列表
     */
    @ApiOperation("导出微信App配置列表")
    @PreAuthorize("@ss.hasPermi('base:wxapp_config:export')")
    @Log(title = "微信App配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxappConfig wxappConfig)
    {
        List<WxappConfig> list = wxappConfigService.selectWxappConfigList(wxappConfig);
        ExcelUtil<WxappConfig> util = new ExcelUtil<WxappConfig>(WxappConfig.class);
        util.exportExcel(response, list, "微信App配置数据");
    }

    /**
     * 获取微信App配置详细信息
     */
    @ApiOperation("获取微信App配置详细信息")
    @PreAuthorize("@ss.hasPermi('base:wxapp_config:query')")
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") Long configId)
    {
        return success(wxappConfigService.selectWxappConfigByConfigId(configId));
    }

    /**
     * 新增微信App配置
     */
    @ApiOperation("新增微信App配置")
    @PreAuthorize("@ss.hasPermi('base:wxapp_config:add')")
    @Log(title = "微信App配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxappConfig wxappConfig)
    {
        return toAjax(wxappConfigService.insertWxappConfig(wxappConfig));
    }

    /**
     * 修改微信App配置
     */
    @ApiOperation("修改微信App配置")
    @PreAuthorize("@ss.hasPermi('base:wxapp_config:edit')")
    @Log(title = "微信App配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxappConfig wxappConfig)
    {
        return toAjax(wxappConfigService.updateWxappConfig(wxappConfig));
    }

    /**
     * 删除微信App配置
     */
    @ApiOperation("删除微信App配置")
    @PreAuthorize("@ss.hasPermi('base:wxapp_config:remove')")
    @Log(title = "微信App配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable Long[] configIds)
    {
        return toAjax(wxappConfigService.deleteWxappConfigByConfigIds(configIds));
    }
}
